<template>
    <view class="list-item flex-vertical-center" @click="jumpDetail">
        <view class="left">
            <image class="img" :src="requestUrl + item.pic" mode="aspectFill"></image>
        </view>
        <view class="right"> 
            <view class="title flex-between">
                <view class="name text-overflow">{{ item.title }}</view>
                <view class="set-top" v-if="item.is_top">置顶</view>
            </view>
            <view class="tag-list flex">
                <block v-if="item.labels">
                    <view class="tag" v-for="(tag, tindex) in tagList" :key="tindex">{{ tag }}</view>
                </block>
            </view>
            <view class="area flex-between text-color-4">
                <view class="area-name text-overflow">{{ item.address }}</view>
                <view class="distance flex-vertical-center">{{ item.distance }}{{ item.distance_text }}</view>
            </view>
        </view>
    </view>
</template>

<script>
    import { requestUrl } from '@/utils/config'
    export default {
        props: {
            item: {
                type: Object,
                default: () => ({})
            }
        },
        computed: {
            tagList(){
                return this.item.labels.split(',')
            }
        },
        data(){
            return {
                requestUrl: requestUrl
            }
        },
        methods: {
            // 跳转店铺详情
			jumpDetail(){
				uni.navigateTo({
					url: '/pages/store/index?id=' + this.item.id + '&district=' + this.item.district.name
				})
			}
        }
    }
</script>

<style lang="scss" scoped>
    .list-item{
        padding: 24rpx;
        background: #fff;
        border-radius: 16rpx;
        margin-bottom: 16rpx;

        .left{
            width: 144rpx;
            height: 142rpx;
            border-radius: 8rpx;
            overflow: hidden;
            background: #f3f3f3;

            .img{
                width: 144rpx;
                height: 142rpx;
            }
        }
        .right{
            width: calc(100% - 144rpx - 16rpx);
            margin-left: 16rpx;
            .title{
                height: 36rpx;
                padding-top: 4rpx;
                align-items: center;
                .name{
                    flex: 1;
                    font-size: 28rpx;
                    font-weight: 500;
                }

                .set-top{
                    background: #FF4433;
                    height: 32rpx;
                    line-height: 32rpx;
                    padding: 0 8rpx;
                    border-radius: 4rpx;
                    color: #fff;
                    font-size: 24rpx;
                }
            }

            .tag-list{
                height: 32rpx;
                padding-top: 8rpx;

                .tag{
                    line-height: 32rpx;
                    background: #FFF2F4;
                    border-radius: 78rpx;
                    font-size: 20rpx;
                    color: #FE4B11;
                    padding: 0 8rpx;
                    margin-right: 8rpx;
                }
            }

            .area{
                padding-top: 26rpx;
                height: 32rpx;
                font-size: 24rpx;

                .area-name{
                    flex: 1;								
                }

                .distance{
                    margin-left: 24rpx;

                    &::before{
                        display: inline-block;
                        content: '';
                        width: 29rpx;
                        height: 27.35rpx;
                        background: url('../static/position.png') center no-repeat;
                        background-size: 29rpx 27.35rpx;
                        margin-right: 4rpx;
                    }
                }
            }
        }
    }
</style>